#include "tls_alloc.h"
#include "tls_connection.h"

TCP_CONNECTION *alloc_connection(void) {
    TCP_CONNECTION *conn;

    conn = kmalloc(sizeof(TCP_CONNECTION), GFP_KERNEL);

    conn->buf = kzalloc(BUFFER_SIZE, GFP_KERNEL);
    if (conn->buf == NULL ) {
        printk("client: recv_buf kmalloc error!\n");
        return NULL;
    }
    conn->ssl = kzalloc(sizeof(SSL_CONNECTION), GFP_KERNEL);
    if (conn->ssl == NULL) {
        printk("client: ssl kmalloc error!\n");
    }
    return conn;
}

void free_connection(TCP_CONNECTION *conn) {
    // kfree(conn->buf);
    // kfree(conn->ssl);
    kfree(conn);
}
